#ifndef PARTICLE_DISPATCH
#define PARTICLE_DISPATCH
#include "Common.hlsl"

RWByteAddressBuffer UpdateIndirectArgumentBuffer;

[numthreads(1, 1, 1)]
void Dispatch(uint3 id : SV_DispatchThreadID)
{
    
    uint a=Simulation_Counter.Load(0);
    
    a=ceil((float)a/THREAD_COUNT);
    UpdateIndirectArgumentBuffer.Store3(0, uint3(a,1,1)); // NumThreadGroupsX, NumThreadGroupsY, NumThreadGroupsZ
}


ByteAddressBuffer Rending_Counter;
RWByteAddressBuffer DrawIndirectArgumentBuffer;
int Render_flag=1;
//0 tri  1 line
[numthreads(1, 1, 1)]
void DispatchDraw(uint3 id : SV_DispatchThreadID)
{
    uint count=Rending_Counter.Load(0);
    if(Render_flag==0)
    {
        DrawIndirectArgumentBuffer.Store4(0, uint4(6,count,0,0)); 
    }
    else if(Render_flag==1)
    {
        DrawIndirectArgumentBuffer.Store4(0, uint4(2,count,0,0)); 
    }
    else
    {
        DrawIndirectArgumentBuffer.Store4(0, uint4(0,0,0,0)); 
    }
    
}
#endif